CC= gcc
CFLAGS= `pkg-config --cflags --libs glib-2.0` -g -Wall -Wextra -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -lglib-2.0
LDFLAGS= 

all:
	@echo '----------------------------------------------------------------';
	@echo '|                     Compilation                              |';
	@echo '----------------------------------------------------------------';
	@echo '--------------> thread.o';
	make thread.o;
	@echo '\n';
	@echo '--------------> fibonacci';
	make fibonacci;
	@echo '\n';
	@echo '--------------> create_many';
	make create_many;
	@echo '\n';
	@echo '--------------> create_many_recursive';
	make create_many_recursive;
	@echo '\n';
	@echo '--------------> switch';
	make switch;
	@echo '\n';
	@echo '--------------> join1';
	make join1;
	@echo '\n';
	@echo '--------------> join1_main';
	make join1_main;
	@echo '\n';
	@echo '--------------> main';
	make main;
	@echo '\n';
	@echo '--------------> switch_many';
	make switch_many;
	@echo '\n';
	@echo '--------------> switch_many_join1';
	make switch_many_join1;
	@echo '\n';
	@echo '--------------> nettoyage';
	make clean;
	@echo '\n';
	@echo '----------------------------------------------------------------';
	@echo '|                      Execution                               |';
	@echo '----------------------------------------------------------------';
	make run;

thread.o: thread.c
	$(CC) $(CFLAGS) -c $<
	
%.o: %.c
	$(CC) $(CFLAGS) -c $<

fibonacci: fibonacci.o thread.h thread.o
	$(CC) $(CFLAGS) $^ -o $@

create_many: create_many.o thread.o
	$(CC) $(CFLAGS) $^ -o $@

create_many_recursive:	create_many_recursive.o thread.o
	$(CC) $(CFLAGS) $^ -o $@

switch:	switch.o thread.o
	$(CC) $(CFLAGS) $^ -o $@

join1: join1.o thread.o
	$(CC) $(CFLAGS) $^ -o $@

join1_main: join1_main.o thread.o
	$(CC) $(CFLAGS) $^ -o $@

main: main.o thread.o
	$(CC) $(CFLAGS) $^ -o $@

switch_many: switch_many.o thread.o
	$(CC) $(CFLAGS) $^ -o $@

switch_many_join1: switch_many_join1.o thread.o
	$(CC) $(CFLAGS) $^ -o $@

run: 
	@echo '--------------> fibonacci 10';
	./fibonacci 10
	@echo '\n';
	@echo '--------------> create_many 5';
	./create_many 5
	@echo '\n';
	@echo '--------------> create_many_recursive 5';
	./create_many_recursive 5
	@echo '\n';
	@echo '--------------> switch';
	./switch
	@echo '\n';
	@echo '--------------> join';
	./join1
	@echo '\n';
	@echo '--------------> join_main';
	./join1_main
	@echo '\n';
	@echo '--------------> main';
	./main
	@echo '\n';
	@echo '--------------> switch_many 4 4';
	./switch_many 4 4
	@echo '\n';
	@echo '--------------> switch_many_join 4 4';
	./switch_many_join1 4 4

clean:	
	rm -rf *.o
